package com.smalls.newvideotwo.utilsErr;

import android.app.Dialog;
import android.content.Context;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;

import com.smalls.newvideotwo.R;
import com.smalls.newvideotwo.utils.AppUtils;

public class BaseErrorDialog extends Dialog {
    private LinearLayout ll_error_msg;
    private TextView tv_loading;

    public BaseErrorDialog(Context mContext, String str, int style, int bg, int width, int height) {
        super(mContext, style);
        View loadingView = LayoutInflater.from(mContext).inflate(R.layout.layout_error_dialog, null);
        this.ll_error_msg = (LinearLayout) loadingView.findViewById(R.id.ll_error_msg);
        if (width > 0 && height > 0) {
            this.ll_error_msg.setLayoutParams(new LayoutParams(AppUtils.DipToPixels(mContext, (float) width), AppUtils.DipToPixels(mContext, (float) height)));
        }
        this.ll_error_msg.setBackgroundResource(bg);
        this.tv_loading = (TextView) loadingView.findViewById(R.id.tv_error_msg);
        setContentView(loadingView);
        this.tv_loading.setText(str);
        getWindow().setFlags(8, 8);
    }

    public void setShowMsg(int paramInt) {
        this.tv_loading.setText(paramInt);
    }

    public void setShowMsg(String paramString) {
        this.tv_loading.setText(paramString);
    }

    public boolean onKeyDown(int keyCode, KeyEvent event) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_BACK:
                if (isShowing()) {
                    dismiss();
                    cancel();
                    return true;
                }
                break;
        }
        return super.onKeyDown(keyCode, event);
    }
}
